package com.example.demo.service.order.impl;

import com.alibaba.fastjson.JSON;
import com.example.demo.common.BaseErrorConfigEnum;
import com.example.demo.common.BasePageResponse;
import com.example.demo.common.ResultObject;
import com.example.demo.common.TerminologyConfigEnum;
import com.example.demo.dao.IProviderDao;
import com.example.demo.dao.IVisaCardDao;
import com.example.demo.jooq.tables.daos.VisaCardDao;
import com.example.demo.jooq.tables.pojos.VisaCard;
import com.example.demo.model.po.ProviderPage;
import com.example.demo.model.po.VisaPage;
import com.example.demo.model.request.ProviderPageRequest;
import com.example.demo.model.request.VisaPageRequest;
import com.example.demo.model.request.VisaRequest;
import com.example.demo.model.response.ProviderResponse;
import com.example.demo.model.response.VisaResponse;
import com.example.demo.service.BaseBusinessServiceImpl;
import com.example.demo.service.order.IProviderService;
import com.example.demo.service.order.IVisaCardService;
import com.example.demo.util.AssertUtils;
import com.example.demo.util.ClazzUtils;
import com.example.demo.util.DateUtils;
import org.modelmapper.TypeToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class IProviderServiceImpl extends BaseBusinessServiceImpl implements IProviderService {
    @Autowired
    private IProviderDao iProviderDao;

    @Override
    public ResultObject<BasePageResponse<ProviderResponse>> queryPageProviderList(ProviderPageRequest providerPageRequest) {
        ResultObject<BasePageResponse<ProviderResponse>> responseResultObject = new ResultObject<>();
        List<ProviderPage> providerPages =  iProviderDao.queryPageProviderList(providerPageRequest);
        if(AssertUtils.isNotEmpty(providerPages)){
            Integer integer =providerPages.get(0).getTotalLine();
            List<ProviderResponse> vpsResponses = (List<ProviderResponse>)this.converterList(providerPages,new TypeToken<List<ProviderResponse>>() {}.getType() );
            BasePageResponse<ProviderResponse> responseBasePageResponse =BasePageResponse.getData(providerPageRequest.getCurrentPage(),providerPageRequest.getPageSize(),integer,vpsResponses);
            responseResultObject.setData(responseBasePageResponse);
        }
        return responseResultObject;
    }
}
